package network;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏西西
 * Date: 2023-10-20
 * Time: 16:53
 */
public class UdpDicSe extends UdpEcSe {
    private Map<String,String> dic = new HashMap<>();
//对于DicSe来说，和UdpEcSe来说大部分的东西是一样的
    public UdpDicSe(int port) throws SocketException {
        super(port);
        //给这个dic设置内容
        dic.put("cat","小猫");
        dic.put("dog","小狗");
        dic.put("pig","小猪");
        //这里可以无限多的设置键值对
    }
    @Override
    public String process(String request){
        //查词典的过程
        return dic.getOrDefault(request,"当前单词查不到！");

    }

    public static void main(String[] args) throws IOException {
        UdpDicSe server = new UdpDicSe(8090);
        server.start();
    }
}
